package jtk.project4.fleet.screen.addEditFuelEntry;

/*
* Author : Rio Dermawan 
* Date Created : 1-April-2011
* Date Modified : 6-April-2011
* Version : 1.1
* */

import java.sql.SQLException;

import jtk.project4.fleet.FleetModel;
import jtk.project4.fleet.domain.Fuel;
import jtk.project4.fleet.event.AddEditFuelEntryEvent;
import nl.coderight.jazz.Controller;

public class AddEditFuelEntryController extends Controller{
	private FleetModel fleetModel;
	private AddEditFuelEntryView addEditFuelEntryView;

	public void handleEvent(AddEditFuelEntryEvent evt) throws SQLException{
		Fuel fuel = fleetModel.getFuel();
		switch (evt.getType()) {
		case SAVE:
			System.out.println(fuel.getComments());
			//System.out.println("demi alek : "+ fuel.getComments());
			fleetModel.insertFuel(fuel);
			break;
		default:
			propagateEvent(evt);
			break;
		}
	}
	
	@Override
	public void execute() {
		fleetModel = (FleetModel) getModel();
		addEditFuelEntryView = new AddEditFuelEntryView();
		setView(addEditFuelEntryView);
		showView();
	}

}
